﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using OgilvyOne.BLL;
using OgilvyOne.Model;

using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;
using System.Collections.Generic;
using ECCIT;
/*修改人：穆凤凤
      * 修改时间：2012-01-02
      * 修改内容：
      *      新增此页面,根绝活动id,获得该活动所有评论的信息页面
      *      有mff注释的为本次修改的代码
      */
//mff
public partial class admin_UKNOW_event_event_comment_list : AdminBasePage
{
    private const string VIEWSTATE_COLUMN_ID = "columnid";
    private const string VIEWSTATE_EVENT_ID = "EventsID";
    private const string VIEWSTATE_LANG_ID = "langID";
    private const string VIEWSTATE_LAYER_ID = "layerid";

    private const string VIEWSTATE_PAGE_NO = "pageNum";//


    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!Page.IsPostBack)
        {
            ViewState[VIEWSTATE_COLUMN_ID] = int.Parse(Request.Params[VIEWSTATE_COLUMN_ID]);
            ViewState[VIEWSTATE_LAYER_ID] = Request.Params[VIEWSTATE_LAYER_ID];
            ViewState[VIEWSTATE_EVENT_ID] = int.Parse(Request.Params[VIEWSTATE_EVENT_ID]);
            //
           // ViewState[VIEWSTATE_EVENT_ID] = int.Parse(Request.Params[((LinkButton)sender).CommandArgument]);
            this.headers.Text = "活动评论列表";
            ViewState[VIEWSTATE_PAGE_NO] = "1";//
            Grid_viewBild();
        }
        else
        {
            if (string.IsNullOrEmpty(ViewState[VIEWSTATE_PAGE_NO].ToString())) return;
            string sPageNum = Request.Params[VIEWSTATE_PAGE_NO];
            if (ViewState[VIEWSTATE_PAGE_NO].ToString() != sPageNum)
            {
                ViewState[VIEWSTATE_PAGE_NO] = sPageNum;
                Grid_viewBild();
            }
        }
    }

        private void Grid_viewBild()
       {
           //int? eventsID = GetEventsIDFromViewState();

           //IList<EventsImageModel> datalist = new EventsImageBLL(LangID).GetAllEventsImageModels(eventsID);
           //GridView1.DataSource = datalist;
           //GridView1.PageSize = 10;
           ////
           //GridView1.PageIndex = int.Parse(ViewState[VIEWSTATE_PAGE_NO].ToString()) - 1;
           ////
           //GridView1.DataBind();
           //this.pagehtml.Text = getPageHtml(GridView1.PageCount, GridView1.PageIndex + 1, datalist.Count);



           //根据活动的ID(部分活动)获取该活动的所有的评论的所有信息

           int Event_ID = int.Parse(ViewState[VIEWSTATE_EVENT_ID].ToString());
           IList<EventsCommentModel> EventsPartialComment = new EventsCommentBLL(LangID).selectcommentbyeventID(Event_ID);
           GridView1.DataSource = EventsPartialComment;
           GridView1.PageSize = 10;
           GridView1.PageIndex = int.Parse(ViewState[VIEWSTATE_PAGE_NO].ToString()) - 1;//
           GridView1.DataBind();
           this.pagehtml.Text = getPageHtml(GridView1.PageCount, GridView1.PageIndex + 1, EventsPartialComment.Count);
       }
//mff
        protected void Add_click(object sender, EventArgs e)
        {
            string url = string.Format("event_comment_add.aspx?{0}={1}&{2}={3}&{4}={5}&{6}={7}", VIEWSTATE_COLUMN_ID, ViewState[VIEWSTATE_COLUMN_ID], VIEWSTATE_EVENT_ID, ViewState[VIEWSTATE_EVENT_ID], VIEWSTATE_LAYER_ID, ViewState[VIEWSTATE_LAYER_ID], VIEWSTATE_LANG_ID, this.LangID);
            Response.Redirect(url);
        }


        /*修改人：穆凤凤
          * 修改时间：2012-01-02
          * 修改内容：
          *      新增此方法,根绝评论id,删除该评论的信息
          *      有mff注释的为本次修改的代码
          */
        //mff
        protected void Del_click(object sender, EventArgs e)
        {
            int eid = int.Parse(((LinkButton)sender).CommandArgument);
            ResultInfo res = new EventsCommentBLL(LangID).delComment(eid);
            if (res.Result)
            {
                Response.Write("<script>alert('" + res.Message + "')</script>");
            }
            else
            {
                Response.Write(res.Message);
            }
            //删除该评论下的所有图片以及数据库中的记录
            //删除评论表里该活动的记录
            Grid_viewBild();
        }
        protected void Set_click(object sender, EventArgs e)
        {
            ////修改单个评论的发布状态
            //int eid = int.Parse(((LinkButton)sender).CommandArgument);
            //new EventsCommentBLL(LangID).modPubOne(eid);
            //Grid_viewBild();
        }
        //mff
        protected void Return_click(object sender, EventArgs e)
        {
            //Response.Redirect("event_list.aspx?EventsID=" + Request.Params["EventsID"]);
            Response.Redirect("event_list.aspx?columnid=" + ViewState[VIEWSTATE_COLUMN_ID] + "&layerid=" + ViewState[VIEWSTATE_LAYER_ID] + "&langID=" + LangID);
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
}